home *** CD-ROM | disk | FTP | other *** search
/ Language/OS - Multiplatform Resource Library / LANGUAGE OS.iso / gnu / dld-3_23.lha / dld-3.2.3 / get_func.c < prev    next >
C/C++ Source or Header  |  1991-05-30  |  1KB  |  52 lines

  1. /* get_func.c -- return the entry point of the given function. */
  2.  
  3. /* This file is part of DLD, a dynamic link/unlink editor for C.
  4.    
  5.    Copyright (C) 1990 by W. Wilson Ho.
  6.  
  7.    The author can be reached electronically by how@cs.ucdavis.edu or
  8.    through physical mail at:
  9.  
  10.    W. Wilson Ho
  11.    Division of Computer Science
  12.    University of California at Davis
  13.    Davis, CA 95616
  14.  */
  15.  
  16. /* This program is free software; you can redistribute it and/or modify it
  17.    under the terms of the GNU General Public License as published by the
  18.    Free Software Foundation; either version 1, or (at your option) any
  19.    later version. */
  20.  
  21. #include "defs.h"
  22.  
  23. /*  given a function name, return the location of that function (in core) */
  24. unsigned long
  25. dld_get_func (name)
  26. char name[];
  27. {
  28.     register symbol *sp;
  29.     register char *p;
  30.  
  31.     if (name == 0)
  32.     return 0;
  33.     
  34.     if (setjmp (_dld_env))
  35.     return 0;
  36.  
  37.     /* prepend a '_' to name, as required by C's convention */
  38.     p = (char *) _dld_malloc (strlen(name) + 2);
  39.     *p = '_';
  40.     strcpy (p+1, name);
  41.  
  42.     sp = _dld_getsym_soft (p);
  43.     free (p);
  44.  
  45.     if (sp)
  46.     if (sp->defined == (N_EXT | N_TEXT))
  47.         return sp->value;
  48.     return 0;
  49. } /* dld_get_func */
  50.  
  51.  
  52.